﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _06_枚举
{
    public class Person:IEnumerable<Person>
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
        private Person[] p = new Person[2];
        private int length = 0;
        public void Add(Person person)
        {
            
            p[length] = person;
            length++;
        }
        public IEnumerator<Person> GetEnumerator()
        {
            foreach (Person item in p)
            {
                yield return item;
            }

           
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}
